package com.hoveagle.kafka.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Closeable;
import java.io.IOException;
import java.util.Arrays;

/**
 * define a tool for operating file
 * Created on 2020/11/23.
 */
public class FileUtil {
    private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);

    public static void close(Closeable...io){
        if (io == null) {
            return;
        }
        Arrays.stream(io).forEach(ioItem -> {
            if(null != ioItem){
                try {
                    ioItem.close();
                } catch (IOException e) {
                    logger.warn("Failed to close io",e);
                }
            }
        });
    }

}
